package com.dell.optimize;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class OptimizeActivity extends Activity implements OnClickListener{
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Button startBtn = (Button)findViewById(R.id.start_btn);
        Button stopBtn = (Button)findViewById(R.id.stop_btn);
        
        startBtn.setOnClickListener(this);
        stopBtn.setOnClickListener(this);
        
        Util.setContext(this);
    }

	public void onClick(View src) {
		System.out.println(" On click");
	    switch (src.getId()) {
	    case R.id.start_btn:
	      Log.d("Recording Activity", "onClick: starting srvice");
	     // Toast.makeText(this, "My Service Started", Toast.LENGTH_LONG).show();
	      Util.startService();
	      
	      break;
	    case R.id.stop_btn:
	      Log.d("Recording Activity", "onClick: stopping srvice");
	      System.out.println(" ");
	     // stopService(new Intent(this, OptimizationService.class));
	      Util.stopService();
	      break;
	    }
	  }
	
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		//Util.stopService();
		super.onDestroy();
		
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// TODO Auto-generated method stub
		menu.add(0, 0, 0, "Settings");
		return true;
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		if(item.getItemId() == 0){
			Intent intent = new Intent(this, SettingsActivity.class);
			startActivity(intent);
			return true;
		}
		return false;
	}
    
}